package com.weiyuwqj.admin.controller.admin.contracts;

import com.weiyuwqj.api.service.SysContractsService;
import com.weiyuwqj.api.common.Paginator;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Yao xiuwei on 2015/12/1.
 */
@Controller
@RequestMapping(value = "/admin/contracts")
public class SysContractsController {
    @Autowired
    SysContractsService contractsService;
    //显示&查询
    @ResponseBody
    @RequestMapping(value = "/getList", method = RequestMethod.POST)
    public Object getList(Paginator paginator,HttpServletRequest request){
        String userId = request.getParameter("userId");
        String title = request.getParameter("title");
        String beginDateTime = request.getParameter("beginDateTime");
        String endDateTime = request.getParameter("endDateTime");
        Map<String, Object> map = new HashMap<String, Object>();
        if(StringUtils.isNotEmpty(userId)){
            map.put("userId", userId);
        }
        if(StringUtils.isNotEmpty(title)){
            map.put("title", title);
        }
        if(StringUtils.isNotEmpty(beginDateTime)){
            map.put("beginDateTime", beginDateTime);
        }
        if(StringUtils.isNotEmpty(endDateTime)){
            map.put("endDateTime", endDateTime);
        }
        return contractsService.getList(paginator, map);
    }
}
